﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TimKen.BussLogic;
using TimKen.App;
using TimKen.DataEntity;
using System.Data;

namespace TimKen.Web.UserControls
{
    public partial class UserCenter : TimKen.App.BaseUserControl
    {
        public ShopCartSet ShopCart
        {
            get
            {
                if (Session["ShopCartSet"] == null)
                {
                    Session["ShopCartSet"] = new ShopCartSet();
                }
                return (ShopCartSet)Session["ShopCartSet"];

            }
            set
            {
                Session["ShopCartSet"] = value;
            }
        }
        /// <summary>
        /// 历史订单数量
        /// </summary>
        public int OrderSize
        {
            get
            {
                OrderManager om = new OrderManager();
                int count = om.GetOrderCount(CurrentUserName);
                //DataSet dss = frms.GetList(" UserName=" + "'" + CurrentUserName + "'");
                return count != 0 ? count : 0;
            }
            set
            {
                ViewState["OrderSize"] = value;
            }
        }
        /// <summary>
        /// 我的收藏
        /// </summary>
        public int FavoriteSize
        {
            get
            {
                return ViewState["FavoriteSize"] == null ? 0 : Convert.ToInt32(ViewState["FavoriteSize"]);
            }
            set
            {
                ViewState["FavoriteSize"] = value;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                OrderManager om = new OrderManager();
                System.Data.DataSet ds = om.GetList(10, 1, "", "", "", 0, 0, -1, "", "", "", "", CurrentUserName, (int)OrderType.Order, LanguageID);
                OrderSize = Convert.ToInt32(ds.Tables[1].Rows[0]["total"]);

                TimKen.BussLogic.FavoriteManager frm = new TimKen.BussLogic.FavoriteManager();
                System.Data.DataSet dsf = frm.GetPageList(10, 1, CurrentUserName, LanguageID);
                FavoriteSize = Convert.ToInt32(dsf.Tables[1].Rows[0]["total"]);
            }
        }
    }
}